//
//  BFManagerViewController.m
//  BFoodSystem
//
//  Created by 浙江择富 on 2018/3/14.
//  Copyright © 2018年 陈名正. All rights reserved.
//

#import "BFManagerViewController.h"
#import "BFManagerTableViewCell.h"

@interface BFManagerViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,strong) UITableView *tabView;
//店铺管理
@property(nonatomic, strong)NSMutableArray *dataArr;
//统计数据
@property(nonatomic, strong)NSMutableArray *queryDataArr;
//店员管理
@property(nonatomic, strong)NSMutableArray *shopMemberDataArr;
//客户（会员）管理
@property(nonatomic, strong)NSMutableArray *insiderDataArr;

@end

@implementation BFManagerViewController
//统计报表
- (NSMutableArray *)queryDataArr{
    if (!_queryDataArr) {
        NSMutableDictionary *dic1 = [@{@"icon":@"iconTj",@"title":@"报表查询",@"budge":@"",@"pushSegue":@"",@"vcClass":@"BFQueryYearController"} mutableCopy];
        
        NSMutableDictionary *dic2 = [@{@"icon":@"iconLs",@"title":@"查询单日流水",@"budge":@"",@"pushSegue":@"",@"vcClass":@"BFQueryTodayController"}mutableCopy];
        
        NSMutableDictionary *dic3 = [@{@"icon":@"iconCp",@"title":@"菜品销售统计",@"budge":@"",@"pushSegue":@"",@"vcClass":@"BFQueryFoodController"}mutableCopy];
        
        NSMutableDictionary *dic4= [@{@"icon":@"iconCx",@"title":@"菜品撤销记录",@"budge":@"",@"pushSegue":@"agentID",@"vcClass":@"BFQueryOffSaleController"} mutableCopy];
        _queryDataArr = [NSMutableArray arrayWithObjects:dic1,dic2,dic3,dic4, nil];
    }
    return _queryDataArr;
    
}
//店员管理
- (NSMutableArray *)shopMemberDataArr{
    if (!_shopMemberDataArr) {
         NSMutableDictionary *dic1 = [@{@"icon":@"icon_dianyuan",@"title":@"店员管理",@"budge":@"",@"pushSegue":@"",@"vcClass":@"BFWaiterMangerController"}mutableCopy];
        _shopMemberDataArr = [NSMutableArray arrayWithObjects:dic1, nil];
        
    }
    return _shopMemberDataArr;
}

//店面管理
- (NSMutableArray *)dataArr{
    if (!_dataArr) {
        NSMutableDictionary *dic1 = [@{@"icon":@"iconShop",@"title":@"店面管理",@"budge":@"",@"pushSegue":@"",@"vcClass":@"BFShopMangerController"} mutableCopy];
        
        NSMutableDictionary *dic2 = [@{@"icon":@"iconTable",@"title":@"餐台管理",@"budge":@"",@"pushSegue":@"",@"vcClass":@"BFDeskAreaController"}mutableCopy];
        
        NSMutableDictionary *dic3 = [@{@"icon":@"iconMenu",@"title":@"菜品管理",@"budge":@"",@"pushSegue":@"",@"vcClass":@"BFFoodMangerController"}mutableCopy];
        
        NSMutableDictionary *dic4= [@{@"icon":@"iconAuth",@"title":@"商家认证",@"budge":@"",@"pushSegue":@"agentID",@"vcClass":@"BusnessAuthorViewController"} mutableCopy];
        
        _dataArr = [NSMutableArray arrayWithObjects:dic1,dic2,dic3,dic4, nil];
    }
    return _dataArr;
}

//客户（会员）管理
- (NSMutableArray *)insiderDataArr{
    if (!_insiderDataArr) {
         NSMutableDictionary *dic1 = [@{@"icon":@"icon_kehu",@"title":@"客户管理",@"budge":@"",@"pushSegue":@"",@"vcClass":@"BFClientsManagerController"} mutableCopy];
        
        _insiderDataArr = [NSMutableArray arrayWithObjects:dic1, nil];
        
    }
    return _insiderDataArr;
}
- (UITableView *)tabView{
    if (!_tabView) {
                _tabView = [[UITableView alloc] initWithFrame:self.view.frame];
                _tabView.delegate = self;
                _tabView.dataSource = self;
                _tabView.backgroundColor = [UIColor clearColor];
                _tabView.separatorStyle = UITableViewCellSeparatorStyleNone;
                _tabView.rowHeight = 80;
                _tabView.layer.cornerRadius = 10;
                _tabView.layer.masksToBounds = YES;
                [_tabView registerNib:[UINib nibWithNibName:NSStringFromClass([BFManagerTableViewCell class]) bundle:nil] forCellReuseIdentifier:@"BFManagerTableViewCell"];
        //
    }
    return _tabView;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self.view addSubview:self.tabView];
    self.view.backgroundColor = [UIColor clearColor];
    
}

#pragma   --------------UITableViewDelegate
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    //    NSInteger index = self.selectIndex;
    switch (self.index) {
        case 0:
            return self.queryDataArr.count;
            break;
        case 1:
            return self.dataArr.count;
            break;
        case 2:
            return self.shopMemberDataArr.count;
            break;
        case 3:
            return self.insiderDataArr.count;
            break;
        default:
            break;
    }
    
    return 0;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    BFManagerTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"BFManagerTableViewCell"];
    switch (self.index) {
        case 0:
        {
            NSDictionary *dic = self.queryDataArr[indexPath.row];
            [cell configMangerCellWithImageName:[dic objectForKey:@"icon"] titleName:[dic objectForKey:@"title"]];
        }
            
            break;
        case 1:
        {
            NSDictionary *dic = self.dataArr[indexPath.row];
            [cell configMangerCellWithImageName:[dic objectForKey:@"icon"] titleName:[dic objectForKey:@"title"]];
        }
            break;
        case 2:
        {
            NSDictionary *dic = self.shopMemberDataArr[indexPath.row];
            [cell configMangerCellWithImageName:[dic objectForKey:@"icon"] titleName:[dic objectForKey:@"title"]];
        }
            break;
        case 3:
        {
          NSDictionary *dic = self.insiderDataArr[indexPath.row];
            [cell configMangerCellWithImageName:[dic objectForKey:@"icon"] titleName:[dic objectForKey:@"title"]];
        }
            break;
        default:
            break;
    }
    return cell;
    
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
    NSDictionary *dic;
    
    switch (self.index) {
        case 0:
        {
            dic  = self.queryDataArr[indexPath.row];
        }
            break;
        case 1:
        {
            
            dic  = self.dataArr[indexPath.row];
            
            
        }
            break;
        case 2:
        {
             dic  = self.shopMemberDataArr[indexPath.row];
            
        }
            break;
        case 3:
        {
            dic  = self.insiderDataArr[indexPath.row];
            
        }
            break;
        default:
            break;
    }
    
    NSString *vcClass = [dic objectForKey:@"vcClass"];
    if (![vcClass isEqualToString:@""]) {
        Class secClass = NSClassFromString(vcClass);
        UIViewController *secVc = [[secClass alloc] init];
        [self.navigationController pushViewController:secVc animated:YES];
        return;
        
    }
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
